
/* File name	: timer.c
 * Project 		: BKIT MCR
 * Version 		: 1.0
 * Creation Date: 07/07/2010
 * Tabsize		: 4
 * Author  		: BKIT4U                   
 * Copyright	: (c) 2010 BKIT HARDWARE CLUB - www.bkit4u.com
 * License		: Free.
 * Comments		: 
 * 
 */

/*====================================*/
/*  Include                           */
/*====================================*/
#include <avr/interrupt.h>
#include "timer.h"

/*====================================*/
/*	Global Variable Declaration       */
/*====================================*/
unsigned long   cnt0;                   
unsigned long   cnt1;    
unsigned long   cnt2;
unsigned long   cnt3;

/*====================================*/
/*  Function name: timer_init         */
/*  Parameter: null                   */
/*  Description: configure hardware   */
/*               for timer function   */
/*====================================*/
void timer_init()
{	
	cnt0 = cnt1 = cnt2 = cnt3 = 0;

	// Timer/Counter 1 initialization
    // Clock source: System Clock
    // Clock value: 16000.000 kHz
    // Mode: Normal top=FFFFh
    // Timer 1 Overflow Interrupt: On
    TCCR1A=0x00;
    TCCR1B=0x01;
    TCNT1H=0x00;
    TCNT1L=0x00;

	TIMSK|=0x04;
}


/*====================================*/
/*  Function name: virtual_timer      */
/*  Parameter: null                   */
/*  Description: virtual timer        */
/*           virtual delay to use in  */
/*           algorithm                */ 
/*====================================*/
void virtual_timer(){
	cnt0 ++;
	cnt1 ++;
	cnt2 ++;
	cnt3 ++;
}


/****************END FILE**************/

